// pages/like/like.js
Page({
  /**
   * 页面的初始数据
   */
  data: {
  
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
      var that = this;
      wx.request({
          url: 'https://www.mayizhihuan.com/Home/My/love/',
          data: {
              PHPSESSID: wx.getStorageSync('sid')
          },
          method: 'GET',
          header: {
              'content-type': 'application/json'
          },
          success: function (res) {
              that.setData({
                  like: res.data.datas
              })
          }
      })
  },
  details: function () {
      wx.navigateTo({
          url: '../details/details'
      })
  },
  changeColor: function (res) {
      var like = this.data.like.slice(0);
      var tL = like.length
      for (var i = 0; i < tL; i++) {
          if (res.target.id == like[i].article_id) {
              if (like[i].is_share == "true") {
                  like[i].is_share = "false";
                  like[i].sun--
              } else {
                  like[i].is_share = "true";
                  like[i].sun++
              }
          }
      }
      this.setData({
          like: like
      })
      var that = this;
      wx.request({
          url: 'https://www.mayizhihuan.com/Home/Articlelittle/conllection/',
          data: {
              article_id: res.target.id,
              PHPSESSID: wx.getStorageSync('sid')
          },
          method: 'GET',
          header: {
              'content-type': 'application/json'
          },
          success: function (res) {
              
          }
      })
  },
  /**
  * 用户点击右上角分享
  */
  onShareAppMessage: function () {

  }
})